# 添加分组——》修改分组——》删除你刚新增的分组
# project_url = "http://60.205.190.66:8899"
# import requests,random
# # 登录
# response = requests.post(url = project_url + "/adminapi/login",json ={"account":"admin","pwd":"920509","imgcode":"a"})
# token = response.json()['data']['token']
#
# # 添加分组
# random_num = random.randint(1,99999)
# response1 = requests.post(url = project_url + "/adminapi/user/user_group/save.html",json = {"group_name":"小天才" + str(random_num)},headers={"Authori-Zation":
#                                                                                                                                            "Bearer "+str(token)}) # 小天才1  小天才6
# msg = response1.json()['msg']
# assert msg == "提交成功！"
# list_id = []
#
# # 修改分组 - 步骤1，拿到id
# response2 = requests.get(url = project_url + "/adminapi/user/user_group/list?page=1&limit=15",headers={"Authori-Zation":"Bearer "+str(token)})
#
# for i in response2.json()['data']['list']:
#     if i['group_name'] == "小天才" + str(random_num):
#         list_id.append(i['id'])# 拿到id
# #修改分组 - 步骤2  传入id进行修改
# response3 = requests.post(project_url+"/adminapi/user/user_group/save.html",json = {"id":list_id[0],"group_name":"小天才plus"},headers={"Authori-Zation":
#                                                                                                                                            "Bearer "+str(token)})
# assert response3.json()['msg'] == "提交成功！"
#
# # 删除分组
# response4 = requests.delete(project_url+"/adminapi/user/user_group/del/" + str(list_id[0]),headers={"Authori-Zation":"Bearer "+str(token)})
# assert response4.json()['msg'] == "删除成功!"

# 课堂练习：
# 添加话术——》修改话术——》删除你刚新增的话术
# import requests
# from faker import Faker
# 
# class CRMEB:
#     project_url= "http://60.205.190.66:8899"
#     faker = Faker(locale='zh_cn')
#     def login(self):
#         response = requests.post(url=self.project_url + "/adminapi/login",
#                                  json={"account": "admin", "pwd": "920509", "imgcode": "a"})
#         token = response.json()['data']['token']
#         return "Bearer " + str(token)
#     def add(self):
#         self.name = self.faker.name()
#         response1 = requests.post(self.project_url + "/adminapi/app/wechat/speechcraft",json = {"cate_id":"","title":"测试十七期","message":str(self.name),"sort":0},
#                                  headers= {"Authori-Zation":self.login()})
#         assert response1.json()['msg'] == "创建话术成功"
#         # 步骤一，先查
#         response2 = requests.get(self.project_url + "/adminapi/app/wechat/speechcraft?page=1&limit=15&cate_id=",headers={"Authori-Zation":self.login()})
#         for i in response2.json()['data']['list']:
#             if i['message'] == str(self.name):
#                 self.id = i['id']
# 
#         # 步骤二：修改
#         response3 = requests.put(self.project_url + "/adminapi/app/wechat/speechcraft/" + str(self.id),json = {"cate_id":0,"title":"测试十七期",
#                                                                                                                "message":str(self.faker.name()),"sort":0},
#                      headers={"Authori-Zation":self.login()})
#         assert response3.json()['msg'] == "修改成功"
# 
#         # 删除
#         response4=requests.delete(self.project_url + "/adminapi/app/wechat/speechcraft/"+ str(self.id),headers={"Authori-Zation":self.login()})
#         assert response4.json()['msg'] == "删除成功"
# 
# 
# CRMEB().add()